package com.example.yiqiuser.controller;


import com.example.yiqiuser.entity.ScenicTicket;
import com.example.yiqiuser.service.ScenicTicketService;
import com.example.yiqiuser.util.Page;

import com.example.yiqiuser.util.Result;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

import java.util.List;

/**
 * @ fileName:ScenicTicketController
 * @ description:
 * @ createTime:2023/3/30 11:30
 * @ version:1.0.0
 * @author 诸葛龙辰
 */
@RestController
@RequestMapping("scenicticket")
public class ScenicTicketController extends BaseController {

    @Autowired
    private ScenicTicketService scenicTicketService;

    /**
     * 分页带参查询
     * @param page
     * @return
     */
    @PostMapping("page")
    public Result queryPage(@RequestBody Page<ScenicTicket> page){
        return  success(scenicTicketService.queryByParam(page));
    }

    /**
     * 添加
     * @param scenicTicket
     * @return
     */
    @PostMapping("add")
    public Result add(@RequestBody ScenicTicket scenicTicket){
        return success(scenicTicketService.add(scenicTicket));
    }

    /**
     * 更新
     * @param scenicTicket
     * @return
     */
    @PostMapping("update")
    public Result update(@RequestBody ScenicTicket scenicTicket){
        return success(scenicTicketService.update(scenicTicket));
    }

    /**
     * 删除
     * @param id
     * @return
     */
    @DeleteMapping("/{id}")

    public Result deleteById(@PathVariable String id){
        return success(scenicTicketService.deleteById(id));
    }

    /**
     * 单个查询
     * @param id
     * @return
     */
    @GetMapping("/{id}")
    public Result getList(@PathVariable Integer id){
        return success(scenicTicketService.getTickets(id));
    }

    /**
     * 单个查询
     * @param id
     * @return
     */
    @GetMapping("queryById")
    public Result ticket(Integer id){

        return success(scenicTicketService.queryById(id));
    }
}
